package
{
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;

	public class InfoData
	{
		private var xml:XML;
		private var urlloader:URLLoader;
		private var itemArray:Array;
		private var mailArray:Array;
		private var systemArray:Array;
		private var allArray:Array;
		
		public function InfoData(url:String)
		{
			urlloader = new URLLoader();
			urlloader.load(new URLRequest(url));
			urlloader.addEventListener(Event.COMPLETE,loadXMLComplete);
		}
		
		private function loadXMLComplete(e:Event):void
		{
			xml = XML(urlloader.data);
			itemArray = [];
			mailArray = [];
			systemArray = [];
			allArray = [];
			
			for each(var item:XML in xml.catalog)
			{
				itemArray.push({item:item.@name});
			}
			//trace(itemArray[1].item);
			
			for each(var mail:XML in xml.catalog.(@name=="mail").item)
			{
				mailArray.push({list:mail.list,message:mail.message});
			}
			//trace(mailArray[0].list);
			for each(var system:XML in xml.catalog.(@name=="system").item)
			{
				systemArray.push({list:system.list,message:system.message});
			}
			//trace(systemArray[0].list);
			
			allArray.push(mailArray,systemArray);
		}
		
		public function get itemObj():Array
		{
			return itemArray;
		}
		
		public function get listObj():Array
		{
			return allArray;
		}
	}
}